console.log('-----------------------------------------------------');
const m = new Map([['key1','val1'],['key2','val2'],['key3','val3']]);
console.log(m.entries === m[Symbol.iterator]);//true
for(let pairs of m.entries()){
    console.log(pairs);
}
// [ 'key1', 'val1' ]
// [ 'key2', 'val2' ]
// [ 'key3', 'val3' ]
for(let pairs of m[Symbol.iterator]()){
    console.log(pairs);
}
// [ 'key1', 'val1' ]
// [ 'key2', 'val2' ]
// [ 'key3', 'val3' ]
console.log([...m]);//[ [ 'key1', 'val1' ], [ 'key2', 'val2' ], [ 'key3', 'val3' ] ]
console.log('------------------------------------------------------');
m.forEach((val,key)=>{
    console.log(`${key}------${val}`);
});
// key1------val1
// key2------val2
// key3------val3
console.log('------------------------------------------------------');
for(let key of m.keys()){
    console.log(key);
}
// key1
// key2
// key3
for(let value of m.values()){
    console.log(value);
}
// val1
// val2
// val3
console.log('------------------------------------------------------');
const m1 = new Map([["key1","val1"]]);
for(let key of m1.keys()){
    key = 'newKey';
    console.log(key);//newKey
    console.log(m1.get(key));//undefined
    console.log(m1.get('key1'));//val1
}
console.log(m1.keys());//[Map Iterator] { 'key1' }

const obj = {id:1};
const m2 = new Map([[obj,'val1']]);
for(let key of m2.keys()){
    key.id = "newKey",
    console.log(key);//{ id: 'newKey' }
    console.log(m2.get(key));//val1
}